# $Id: PKGBUILD 85746 2013-03-06 08:27:19Z mtorromeo $
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgname=openfire
pkgver=3.8.1
pkgrel=1
pkgdesc="High performance XMPP (Jabber) server."
arch=('any')
url='http://www.igniterealtime.org/projects/openfire/'
license=('GPL')
depends=('java-runtime-headless')
makedepends=('apache-ant')
install='openfire.install'
backup=(
	'etc/openfire/openfire.xml' 'etc/openfire/openfire.xml' 'etc/openfire/openfire.xml' \
	'etc/conf.d/openfire' 'etc/openfire/security/keystore' 'etc/openfire/security/truststore' \
	'etc/openfire/security/client.truststore')
source=("http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire_src_${pkgver//./_}.tar.gz" \
	'openfire.conf' 'openfire.service')

build() {
	cd "$srcdir/openfire_src/build"
	rm -rf ../src/resources/nativeAuth/
	ant openfire
# 	ant plugins
}

package() {
	cd "$srcdir/openfire_src/target/openfire"

	install -dm755 "$pkgdir/usr/lib" "$pkgdir/usr/share/openfire/resources"
	install -dm750 "$pkgdir/etc/openfire" "$pkgdir/var/log/openfire"

	install -Dm644 "$srcdir/openfire.conf" "$pkgdir/etc/conf.d/openfire"
	install -Dm644 "$srcdir/openfire.service" "$pkgdir/usr/lib/systemd/system/openfire.service"

	rm -rf bin logs

	cp -R conf/* "$pkgdir/etc/openfire/"
	ln -s /etc/openfire "$pkgdir/usr/share/openfire/conf"

	cp -R resources/security "$pkgdir/etc/openfire/"
	ln -s /etc/openfire/security "$pkgdir/usr/share/openfire/resources/security"

	cp -R plugins "$pkgdir/usr/share/openfire/"
	cp -R resources/{database,spank} "$pkgdir/usr/share/openfire/resources/"
	cp -R lib "$pkgdir/usr/lib/openfire"
}

sha256sums=('554dce3a1b0a0b883ab0fd4a06a0cee136df9e998f19c53d91a8b5e54ada8604'
            'c8a612abee90bdc9a2869e562a4bbbf596159c60adcd23368833a0e2ca27c1d4'
            '772332b66a90935ddb8075eb10eab9b95a84caa45908bb3fa5861d7fa148399c')
